package fr.imag.adele.mediation.probes.util;

import java.util.Date;
import java.util.Dictionary;
import java.util.Hashtable;

public class DataEvent {	
	private Dictionary	m_data;
	public final static String CP_EVENT_RESOURCE 	= "cp.event.resource";
	public final static String CP_EVENT_SOURCE 		= "cp.event.source";
	public final static String CP_EVENT_TIMESTAMP 	= "cp.event.timestamp";
	public final static String CP_EVENT_VALUE 		= "cp.event.value";
	public final static String CP_EVENT_UNIT 		= "cp.event.unit";
	
	public DataEvent(String resource, String source, String timeStamp, 
			Object value, String unit, Dictionary extraData){
		m_data = new Hashtable();
		m_data.put(DataEvent.CP_EVENT_RESOURCE, resource);
		m_data.put(DataEvent.CP_EVENT_SOURCE, source);
		m_data.put(DataEvent.CP_EVENT_TIMESTAMP, new Date().toString());		
		m_data.put(DataEvent.CP_EVENT_VALUE, value);
		m_data.put(DataEvent.CP_EVENT_UNIT, unit);
		
		/*Enumeration e = extraData.keys();
		while (e.hasMoreElements()){
			String key = (String)e.nextElement();
			m_data.put(e, extraData.get(e));
		}*/
	}
	public String getResource(){
		return (String)this.m_data.get(DataEvent.CP_EVENT_RESOURCE);
	}
	public String getSource(){
		return (String)this.m_data.get(DataEvent.CP_EVENT_SOURCE);
	}	
	public String getTimeStamp(){
		return (String)this.m_data.get(DataEvent.CP_EVENT_TIMESTAMP);
	}
	public Object getValue(){
		return this.m_data.get(DataEvent.CP_EVENT_VALUE);
	}
	public String getUnit(){
		return (String)this.m_data.get(DataEvent.CP_EVENT_UNIT);
	}
	public Dictionary getData(){
		return this.m_data;
	}
	public Object getDataInfo(Object key){		
		return m_data.get(key);
	}
	public void setSource(String source){
		this.m_data.remove(DataEvent.CP_EVENT_SOURCE);
		m_data.put(DataEvent.CP_EVENT_SOURCE, source);
	}
	public void setTimeStamp(String timeStamp){
		this.m_data.remove(DataEvent.CP_EVENT_TIMESTAMP);
		m_data.put(DataEvent.CP_EVENT_TIMESTAMP, timeStamp);
	}
}
